package binarySearch;

public class BinarySearchSo {

    public static void main(String[] args) {
        BinarySearchSo so = new BinarySearchSo();
        int[] nums = {0,1,2,3,4,5,6,7,9};
        System.out.println(so.missingNumber(nums));
    }

    public int missingNumber(int[] nums) {
       int left =0 ,right =nums.length-1;
       while (left<=right){
           int mid = (left + right)/2;
           if (mid == nums[mid]){

           }
       }
       return 0;
    }

    public int search(int[] nums,int left,int right){
        if (left>right){
            return -1;
        }
        int result = 0;
        int mid = (left+right)/2;
        if (nums[mid] > nums[left]+mid){
            //缺少的在左边
            if (nums[mid] -1 == nums[mid-1]){
                //递归
                search(nums, left, mid-1);
            }else{
                result = nums[mid]-1;
            }
        }else if (nums[mid] == nums[left]+mid){
            //缺少的在右边
            if (nums[mid]+1 == nums[mid+1]){
                //递归
                search(nums, mid+1, right);
            }else{
                //找到
                result = nums[mid]+1;

            }
        }
        return result;
    }
}
